﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using X23.Application.ExcelManagement.Dto;
using X23.Model.Excel;
using X23.Util.LinqUtil;

namespace X23.Application.ExcelManagement
{
    public interface IExcelManagementService
    {
        /// <summary>
        /// 添加任务
        /// </summary>
        /// <param name="taskPerformanceDto"></param>
        /// <returns></returns>
        Task<TaskPerformanceDto> AddTaskPerformance(TaskPerformanceDto taskPerformanceDto);
        /// <summary>
        /// 获取导出任务
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<TaskPerformanceDto> GetTaskPerformance(int id);
        /// <summary>
        /// 查询任务执行情况
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageData<TaskPerformanceDto>> GetTaskPerformancePageData(QueryTaskPerformanceDto input);

        /// <summary>
        /// 下载文件流
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="fileType">尾缀</param>
        /// <returns></returns>
        public MemoryStream DownFileStream(string guid, string fileType);

        ///// <summary>
        ///// 导出文件
        ///// </summary>
        ///// <param name="code"></param>
        ///// <param name="fileName"></param>
        ///// <param name="obj"></param>
        ///// <param name="method"></param>
        ///// <param name="parameters"></param>
        ///// <param name="isCap"></param>
        ///// <returns></returns>
        //[Obsolete("暂时有问题！！！", false)]
        //Task<string> Export(string code, string fileName, object obj, string method, object parameters, bool isCap = false);

        ///// <summary>
        ///// 导出
        ///// </summary>
        ///// <param name="queryFunc"></param>
        ///// <param name="tempFileName">文件名称</param>
        ///// <param name="isImmediately">是否立刻</param>
        ///// <returns></returns>
        //Task<MemoryStream> Export(Func<Task<PageData<T>>> queryFunc, string tempFileName, bool isImmediately = false);

        //Task<MemoryStream> ExportDataCap(ExcelDto<T> excelDto);

        /// <summary>
        /// 获取导出文件任务
        /// </summary>
        /// <param name="exportDto"></param>
        /// <returns></returns>
        Task<TaskPerformance> GetExportTask(ExportDto exportDto);

        /// <summary>
        /// 导出核心方法
        /// </summary>
        /// <typeparam name="TQuery"></typeparam>
        /// <typeparam name="TRes"></typeparam>
        /// <param name="input"></param>
        /// <param name="func"></param>
        /// <param name="taskPerformanceId"></param>
        /// <returns></returns>
        Task Export<TQuery, TRes>(TQuery input, Func<TQuery, Task<PageData<TRes>>> func, int taskPerformanceId);


        /// <summary>
        /// excel转换data
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="taskPerformanceId"></param>
        /// <returns></returns>
        Task<List<T>> ConvertExcelToData<T>(int taskPerformanceId);
    }
}
